package com.liu.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")
public class LoginController {
@RequestMapping("/login")
    public String login(HttpSession session , String username, String password, Model model){
//    把用户信息存在session中
    session.setAttribute("UserLogInfo",username);
    model.addAttribute("username",username);
return "main";
    }
    @RequestMapping("/main")
    public String main(){
    return "main";
    }
    @RequestMapping("/goLogin")
    public String login(){
        return "login";
    }

    @RequestMapping("/goOut")
    public String goOut(HttpSession session){
//    把用户信息存在session中
        session.removeAttribute("UserLogInfo");

        return "login";
    }
}
